import java.util.Scanner;

class Num {
    private long integer;
    private long numerator;
    private long denominator;
    private int flag;

    public int getFlag() {
        return flag;
    }

    public void setFlag(int flag) {
        this.flag = flag;
    }

    public long getInteger() {
        return integer;
    }

    public void setInteger(long integer) {
        this.integer = integer;
    }

    public long getNumerator() {
        return numerator;
    }

    public void setNumerator(long numerator) {
        this.numerator = numerator;
    }

    public long getDenominator() {
        return denominator;
    }

    public void setDenominator(long denominator) {
        this.denominator = denominator;
    }

//    @Override
//    public String toString() {
//        return "Num{" +
//                "integer=" + integer +
//                ", numerator=" + numerator +
//                ", denominator=" + denominator +
//                ", flag=" + flag +
//                '}';
//    }

    @Override
    public String toString() {
        return (this.integer == 0 ? "":this.integer+" ")
                +(this.numerator == 0 ? 0+"":this.numerator + "/" + this.denominator);
    }
}
public class Day36 {
    // 1. 输入
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);

        String[] strs = in.nextLine().split(" ");

        // 数据处理
        // 1. 处理正负号
        // 2. 处理分数 5/3 -> 1 2/3
        // 2.1 分数化简涉及到分子分母最小公倍数
        // 2.2 分数相加涉及到分子分母最大公约数
        Num num1 = getInitNum(strs[0]); // 初始化对象1
        Num num2 = getInitNum(strs[1]); // 初始化对象2

        System.out.println(num1 + " + " + num2 + " = " + add(num1,num2));
        System.out.println(num1 + " - " + num2 + " = " + sub(num1,num2));
        System.out.println(num1 + " * " + num2 + " = " + mul(num1,num2));
        System.out.println(num1 + " / " + num2 + " = " + (div(num1,num2) == null?"Inf":div(num1,num2)));


    }


    private static Num add(Num num1,Num num2) {
        Num num = new Num();
        // 整数部分相加
        long integer = num1.getInteger() + num2.getInteger();
        // 分数部分相加
        // 求分母最小公倍数
        long minCommonMultiple = getMinCommonMultiple(num1.getDenominator(),num2.getDenominator());
        // 分母
        long deominator = minCommonMultiple;
        // 分子
        long numerator = num1.getNumerator() * (minCommonMultiple / num1.getDenominator())
                + num2.getNumerator() * (minCommonMultiple / num2.getDenominator());
        if (numerator == 0) {
            num.setInteger(integer);
            num.setNumerator(0);
            return num;
        }
        // 化简
        // 求最大公约数
        long maxCommonDivisor = getMaxCommonDivisor(numerator,deominator);
        deominator = deominator / maxCommonDivisor;
        numerator = numerator / maxCommonDivisor;
        // 封装并返回结果
        num.setInteger(integer);
        num.setDenominator(deominator);
        num.setNumerator(numerator);
        return num;
    }
    private static Num sub(Num num1,Num num2) {
        Num num = new Num();
        // 整数部分相加
        long integer = num1.getInteger() - num2.getInteger();
        // 分数部分相加
        // 求分母最小公倍数
        long minCommonMultiple = getMinCommonMultiple(num1.getDenominator(),num2.getDenominator());
        // 分母
        long deominator = minCommonMultiple;
        // 分子
        long numerator = num1.getNumerator() * (minCommonMultiple / num1.getDenominator())
                - num2.getNumerator() * (minCommonMultiple / num2.getDenominator());
        if (numerator == 0) {
            num.setInteger(integer);
            num.setNumerator(0);
            return num;
        }
        // 化简
        // 求最大公约数
        long maxCommonDivisor = getMaxCommonDivisor(numerator,deominator);
        deominator = deominator / maxCommonDivisor;
        numerator = numerator / maxCommonDivisor;
        // 封装并返回结果
        num.setInteger(integer);
        num.setDenominator(deominator);
        num.setNumerator(numerator);
        return num;

    }
    private static Num mul(Num num1,Num num2) {
        Num num = new Num();
        // 整数部分相乘
        long integer = num1.getInteger() * num2.getInteger();
        // 分数部分相乘
        // 分母
        long deominator = num1.getDenominator() * num2.getDenominator();
        // 分子
        long numerator = num1.getNumerator() * num2.getNumerator();
        if (numerator == 0) {
            num.setInteger(integer);
            num.setNumerator(0);
            return num;
        }
        // 化简
        // 求最大公约数
        long maxCommonDivisor = getMaxCommonDivisor(numerator,deominator);
        deominator = deominator / maxCommonDivisor;
        numerator = numerator / maxCommonDivisor;
        // 封装并返回结果
        num.setInteger(integer);
        num.setDenominator(deominator);
        num.setNumerator(numerator);
        return num;
    }
    private static Num div(Num num1,Num num2) {
        Num num = new Num();
//        // 整数部分相除
//        long integer = num1.getInteger() / num2.getInteger();
        // 分数部分相除
        // 分母
        if (num2.getNumerator() == 0) {
            return null;
        }
        long deominator = num1.getDenominator() * (num2.getNumerator() + (num2.getInteger() * num2.getDenominator()));
        // 分子
        long numerator = (num1.getNumerator() + (num1.getInteger() * num1.getNumerator())) * num2.getDenominator();
        if (numerator == 0) {
            num.setInteger(0);
            num.setNumerator(0);
            return num;
        }
        // 约分
        long integer = numerator / deominator == 0 ? 0 : numerator / deominator;
        long copyNumerator = numerator;
        long copyDenominator = deominator;
        if (copyNumerator % copyDenominator == 0) {
            numerator = 0;
            deominator = deominator;
        } else {
            long maxCommonDivisor = getMaxCommonDivisor(copyNumerator % copyDenominator,copyDenominator);
            numerator = (copyNumerator % copyDenominator) / maxCommonDivisor;
            deominator = deominator / maxCommonDivisor;
        }

        // 设置 Num
        num.setInteger(integer);
        num.setNumerator(numerator);
        num.setDenominator(deominator);
        return num;

    }

    private static Num getInitNum(String str) {
        Num num = new Num();
        // 符号位
        int flag = 1;
        // 分子分母组合串
        String combination = "";
        if (str.charAt(0) == '-') {
            // 有符号位
            // 符号位
            flag = str.charAt(0) == '-' ? -1 : 1;
            combination = str.substring(1);
        } else {
            flag = 1;
            // 没有符号位
            combination = str;
        }
        // 分离分子
        long numerator = Long.valueOf(combination.split("/")[0]);
        // 分离分母
        long denominator = Long.valueOf(combination.split("/")[1]);
        // 约分
        long integer = numerator / denominator == 0 ? 0 : numerator / denominator;
        long copyNumerator = numerator;
        long copyDenominator = denominator;
        if (copyNumerator % copyDenominator == 0) {
            numerator = 0;
            denominator = denominator;
        } else {
            long maxCommonDivisor = getMaxCommonDivisor(copyNumerator % copyDenominator,copyDenominator);
            numerator = (copyNumerator % copyDenominator) / maxCommonDivisor;
            denominator = denominator / maxCommonDivisor;
        }

        // 设置 Num
        num.setInteger(flag*integer);
        num.setNumerator(flag*numerator);
        num.setDenominator(denominator);
        num.setFlag(flag);
        return num;
    }

    private static long getMinCommonMultiple(long m,long n) {
        // 1. 获取两个数的最大公约数
        long maxCommonDivisor = getMaxCommonDivisor(m,n);
        // 2. 返回结果
        return (m * n)/maxCommonDivisor;
    }

    private static long getMaxCommonDivisor(long m,long n) {
        // 辗转相除法
        // 3%2 = 1
        // 2%1 = 0
        while (m % n != 0) {
            long tmp = m;
            m = n;
            n = tmp % n;
        }
        return n;
    }
}
